.class Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;
.super Ljava/lang/Object;
.source "AppInfoManager.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/nemustech/regina/AppInfoManager;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "BitmapCacheLoader"
.end annotation


# instance fields
.field private volatile mRunning:Z

.field private volatile mStopped:Z

.field final synthetic this$0:Lcom/nemustech/regina/AppInfoManager;


# direct methods
.method public constructor <init>(Lcom/nemustech/regina/AppInfoManager;)V
    .locals 1
    .parameter

    .prologue
    .line 250
    iput-object p1, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 251
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mRunning:Z

    .line 252
    return-void
.end method


# virtual methods
.method public isRunning()Z
    .locals 1

    .prologue
    .line 260
    iget-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mRunning:Z

    return v0
.end method

.method public run()V
    .locals 13

    .prologue
    const/4 v12, 0x1

    const/4 v11, 0x0

    .line 264
    const/16 v8, 0xa

    invoke-static {v8}, Landroid/os/Process;->setThreadPriority(I)V

    .line 265
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$000(Lcom/nemustech/regina/AppInfoManager;)Z

    move-result v8

    if-eqz v8, :cond_4

    .line 266
    iput-boolean v12, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mRunning:Z

    .line 267
    iput-boolean v11, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mStopped:Z

    .line 269
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8, v11}, Lcom/nemustech/regina/AppInfoManager;->access$102(Lcom/nemustech/regina/AppInfoManager;Z)Z

    .line 271
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8, v11}, Lcom/nemustech/regina/AppInfoManager;->sendNotificationMessage(I)V

    .line 273
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$200(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/tiffany/util/TFCache;

    move-result-object v8

    invoke-virtual {v8}, Lcom/nemustech/tiffany/util/TFCache;->clear()V

    .line 276
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$300(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v8

    invoke-interface {v8}, Ljava/util/List;->size()I

    move-result v8

    const/16 v9, 0x140

    invoke-static {v8, v9}, Ljava/lang/Math;->min(II)I

    move-result v7

    .line 278
    .local v7, size:I
    const-string v8, "AppInfoManager"

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    const-string v10, "========== Bitmap Cache Loader start (target size : "

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ") =========="

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 280
    const/4 v3, 0x0

    .local v3, i:I
    :goto_0
    if-ge v3, v7, :cond_3

    iget-boolean v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mStopped:Z

    if-nez v8, :cond_3

    .line 283
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$300(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v8

    invoke-interface {v8, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/nemustech/regina/AppInfo;

    .line 284
    .local v0, appInfo:Lcom/nemustech/regina/AppInfo;
    iget-object v6, v0, Lcom/nemustech/regina/AppInfo;->intent:Landroid/content/Intent;

    .line 285
    .local v6, intent:Landroid/content/Intent;
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$400(Lcom/nemustech/regina/AppInfoManager;)Landroid/content/pm/PackageManager;

    move-result-object v8

    invoke-virtual {v8, v6, v11}, Landroid/content/pm/PackageManager;->resolveActivity(Landroid/content/Intent;I)Landroid/content/pm/ResolveInfo;

    move-result-object v5

    .line 286
    .local v5, info:Landroid/content/pm/ResolveInfo;
    if-eqz v5, :cond_2

    .line 287
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$500(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/HashMap;

    move-result-object v8

    invoke-virtual {v6}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/graphics/Bitmap;

    .line 288
    .local v1, bitmap:Landroid/graphics/Bitmap;
    if-eqz v1, :cond_1

    .line 289
    const-string v8, "AppInfoManager"

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    const-string v10, "loading - class name : "

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v10

    invoke-virtual {v10}, Landroid/content/ComponentName;->flattenToString()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 290
    const-string v8, "AppInfoManager"

    const-string v9, "putting Bitmap cache created from element loader in BitmapCacheLoader!"

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 291
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$200(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/tiffany/util/TFCache;

    move-result-object v8

    invoke-virtual {v6}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v9

    invoke-virtual {v9}, Landroid/content/ComponentName;->flattenToString()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9, v1}, Lcom/nemustech/tiffany/util/TFCache;->put(Ljava/lang/String;Landroid/graphics/Bitmap;)V

    .line 300
    :goto_1
    if-eqz v3, :cond_0

    rem-int/lit8 v8, v3, 0x8

    if-nez v8, :cond_0

    .line 301
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8}, Lcom/nemustech/regina/AppInfoManager;->sendNotify()V

    .line 280
    .end local v1           #bitmap:Landroid/graphics/Bitmap;
    :cond_0
    :goto_2
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 293
    .restart local v1       #bitmap:Landroid/graphics/Bitmap;
    :cond_1
    iget-object v8, v5, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

    iget-object v9, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v9}, Lcom/nemustech/regina/AppInfoManager;->access$400(Lcom/nemustech/regina/AppInfoManager;)Landroid/content/pm/PackageManager;

    move-result-object v9

    invoke-virtual {v8, v9}, Landroid/content/pm/ActivityInfo;->loadIcon(Landroid/content/pm/PackageManager;)Landroid/graphics/drawable/Drawable;

    move-result-object v4

    .line 294
    .local v4, icon:Landroid/graphics/drawable/Drawable;
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$600(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/ReginaLauncher;

    move-result-object v8

    invoke-static {v8, v4}, Lcom/nemustech/regina/RUtils;->createIconThumbnail(Landroid/content/Context;Landroid/graphics/drawable/Drawable;)Landroid/graphics/Bitmap;

    move-result-object v1

    .line 295
    const-string v8, "AppInfoManager"

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    const-string v10, "loading - class name : "

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v10

    invoke-virtual {v10}, Landroid/content/ComponentName;->flattenToString()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 296
    const-string v8, "AppInfoManager"

    const-string v9, "putting Bitmap cache in BitmapCacheLoader!"

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 297
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$200(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/tiffany/util/TFCache;

    move-result-object v8

    invoke-virtual {v6}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v9

    invoke-virtual {v9}, Landroid/content/ComponentName;->flattenToString()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9, v1}, Lcom/nemustech/tiffany/util/TFCache;->put(Ljava/lang/String;Landroid/graphics/Bitmap;)V

    goto :goto_1

    .line 304
    .end local v1           #bitmap:Landroid/graphics/Bitmap;
    .end local v4           #icon:Landroid/graphics/drawable/Drawable;
    :cond_2
    const-string v8, "AppInfoManager"

    const-string v9, "application is removed while loading."

    invoke-static {v8, v9}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_2

    .line 308
    .end local v0           #appInfo:Lcom/nemustech/regina/AppInfo;
    .end local v5           #info:Landroid/content/pm/ResolveInfo;
    .end local v6           #intent:Landroid/content/Intent;
    :cond_3
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8}, Lcom/nemustech/regina/AppInfoManager;->clearElementBitmapCache()V

    .line 310
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8}, Lcom/nemustech/regina/AppInfoManager;->cancelNotificationMessage()V

    .line 311
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8, v12}, Lcom/nemustech/regina/AppInfoManager;->sendNotificationMessage(I)V

    .line 312
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8}, Lcom/nemustech/regina/AppInfoManager;->cancelNotificationMessage()V

    .line 314
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8, v12}, Lcom/nemustech/regina/AppInfoManager;->access$102(Lcom/nemustech/regina/AppInfoManager;Z)Z

    .line 315
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-virtual {v8}, Lcom/nemustech/regina/AppInfoManager;->sendNotify()V

    .line 317
    const-string v8, "AppInfoManager"

    const-string v9, "========== Bitmap Cache Loader finished =========="

    invoke-static {v8, v9, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 318
    iget-boolean v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mStopped:Z

    if-nez v8, :cond_4

    .line 319
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$600(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/ReginaLauncher;

    move-result-object v8

    invoke-virtual {v8}, Lcom/nemustech/regina/ReginaLauncher;->getReginaPref()Lcom/nemustech/regina/ReginaPreference;

    move-result-object v8

    invoke-virtual {v8, v12}, Lcom/nemustech/regina/ReginaPreference;->setInitializationStatus(I)V

    .line 320
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$600(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/ReginaLauncher;

    move-result-object v8

    invoke-virtual {v8}, Lcom/nemustech/regina/ReginaLauncher;->getReginaPref()Lcom/nemustech/regina/ReginaPreference;

    move-result-object v8

    invoke-virtual {v8}, Lcom/nemustech/regina/ReginaPreference;->commitPref()Z

    .line 324
    .end local v3           #i:I
    .end local v7           #size:I
    :cond_4
    iput-boolean v11, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mRunning:Z

    .line 325
    iput-boolean v12, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mStopped:Z

    .line 328
    iget-object v8, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-static {v8}, Lcom/nemustech/regina/AppInfoManager;->access$700(Lcom/nemustech/regina/AppInfoManager;)Z

    move-result v8

    if-nez v8, :cond_5

    .line 329
    invoke-static {}, Lcom/nemustech/regina/AppInfoManager;->access$800()Landroid/os/Handler;

    move-result-object v8

    monitor-enter v8

    .line 331
    :try_start_0
    invoke-static {}, Lcom/nemustech/regina/AppInfoManager;->access$800()Landroid/os/Handler;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/Object;->wait()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 335
    :goto_3
    :try_start_1
    monitor-exit v8

    .line 339
    :cond_5
    return-void

    .line 332
    :catch_0
    move-exception v9

    move-object v2, v9

    .line 333
    .local v2, e:Ljava/lang/InterruptedException;
    invoke-virtual {v2}, Ljava/lang/InterruptedException;->printStackTrace()V

    goto :goto_3

    .line 335
    .end local v2           #e:Ljava/lang/InterruptedException;
    :catchall_0
    move-exception v9

    monitor-exit v8
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    throw v9
.end method

.method public stop()V
    .locals 1

    .prologue
    .line 255
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mRunning:Z

    .line 256
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;->mStopped:Z

    .line 257
    return-void
.end method
